//
//  SYKaoQinYiChangDetailsView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/6/14.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYKaoQinYiChangDetailsView.h"
#import "SYTopLabView.h"
#import "SYKaoQinDetailsTableViewCell.h"

@interface SYKaoQinYiChangDetailsView () <UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *curTableView;
@property (strong, nonatomic) SYKaoQinYiChangDetailsView *alterView;
@property (strong, nonatomic) NSMutableArray *dataListArr;


@end

@implementation SYKaoQinYiChangDetailsView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.curTableView.delegate = self;
    self.curTableView.dataSource = self;
    [self.curTableView registerCellWithNIbNames:@[@"SYKaoQinDetailsTableViewCell"]];
    self.curTableView.tableFooterView = [UIView new];
}

#pragma mark - tab

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataListArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SYKaoQinDetailsTableViewCell *detailsCell = [tableView dequeueReusableCellWithIdentifier:@"SYKaoQinDetailsTableViewCell" forIndexPath:indexPath];
    
    detailsCell.studentsModel = self.dataListArr[indexPath.row];
    return detailsCell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 45;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 45;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [[UIView alloc] init];
    
    SYTopLabView *labView = [[SYTopLabView alloc] initWithDataNameArr:@[@"课程名",@"课次",@"标题",@"内容",@"缺勤原因"] width:0.2];
    
    [headerView addSubview:labView];
    
    [labView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(headerView);
        make.left.equalTo(headerView.mas_left).offset(0);
        make.right.equalTo(headerView.mas_right).offset(0);
    }];
    
    
    return headerView;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self removeFromSuperview];
}

- (void)showDetailsView:(SYKaoQinYiChangDetailsView *)detailsView dataListArr:(NSMutableArray *)dataListArr {
    self.dataListArr = dataListArr;
    _alterView = detailsView;
    UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
    detailsView.frame = CGRectMake(0, kScreen_HEIGHT, kScreen_WIDTH, kScreen_HEIGHT);
    [window addSubview:detailsView];
    [UIView animateWithDuration:kAnimate animations:^{
        detailsView.frame = CGRectMake(0, 0, kScreen_WIDTH, kScreen_HEIGHT);
    } completion:^(BOOL finished) {
        [self.curTableView reloadData];
    }];
    
}


@end






















